const express=require("express");
const pool=require("../pool.js");
let router=express.Router();


router.post("/login",(req,res)=>{
  var uname=req.body.uname;
  var upwd=req.body.upwd;
  var sql="SELECT uid FROM xhy_user WHERE uname=? and upwd=?";
  pool.query(sql,[uname,upwd],(err,result)=>{
    if(err) throw err;
    if(result.length==0){
      res.json({code:0,msg:"用户名或密码错误"});
    }else{
      res.json({code:1,msg:"登录成功",name:uname});
    }
  })
})
module.exports=router;
